<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Python," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="Python Number（数字）&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Python Number 数据类型用于存储数值。&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;数据类型是不允许改变的，这就意味着如果改变 Number 数据类型的值，将重新分配内存空间。 &amp;#160;&amp;#160;&amp;#1">
<meta name="keywords" content="Python">
<meta property="og:type" content="article">
<meta property="og:title" content="Python 的数值">
<meta property="og:url" content="https://hcldirgit.github.io/2017/08/10/Python/1. Python 基础篇/1. Python 基础语法/1.5 Python 的数值和字符串/6. Python 的数值/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="Python Number（数字）&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Python Number 数据类型用于存储数值。&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;数据类型是不允许改变的，这就意味着如果改变 Number 数据类型的值，将重新分配内存空间。 &amp;#160;&amp;#160;&amp;#1">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-08-10T05:54:04.157Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Python 的数值">
<meta name="twitter:description" content="Python Number（数字）&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Python Number 数据类型用于存储数值。&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;数据类型是不允许改变的，这就意味着如果改变 Number 数据类型的值，将重新分配内存空间。 &amp;#160;&amp;#160;&amp;#1">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/08/10/Python/1. Python 基础篇/1. Python 基础语法/1.5 Python 的数值和字符串/6. Python 的数值/"/>





  <title>Python 的数值 | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/08/10/Python/1. Python 基础篇/1. Python 基础语法/1.5 Python 的数值和字符串/6. Python 的数值/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Python 的数值</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-10T14:00:36+08:00">
                2017-08-10
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="Python-Number（数字）"><a href="#Python-Number（数字）" class="headerlink" title="Python Number（数字）"></a>Python Number（数字）</h1><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Python Number 数据类型用于存储数值。<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;数据类型是不允许改变的，这就意味着如果改变 Number 数据类型的值，将重新分配内存空间。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;以下实例在变量赋值时 Number 对象被创建：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">var1 = <span class="number">1</span></div><div class="line">var2 = <span class="number">10</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;也可以使用 del 语句删除一些 Number 对象引用。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;del 语句的语法是：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">del</span> var1[,var3[,var3[....,varN]]]]</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;可以通过使用 del 语句删除单个或多个对象：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">del</span> var</div><div class="line"><span class="keyword">del</span> var_a, var_b</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Python 支持四种不同的数值类型</p>
<ul>
<li><strong>整型（int）</strong>-通常被称为是整型或整数，是正或负整数，不带小数点。</li>
<li><strong>长整型(long integers)</strong>-无限大小的整数，证书最后是一个大写或小写的L。</li>
<li><strong>浮点型（floating point real values）</strong>-浮点型由整数部分与小数部分组成，浮点型也可以使用科学计数法表示 （<code>$2.5e2=2.5x10^2=250$</code>）</li>
<li><strong>复数（complex numbers）</strong>-复数由实数部分和叙述部分构成，可以用 a + bj ,或者 complex(a,b) 表示，复数的实部 a 和虚部 b 都是浮点型。</li>
</ul>
<table>
<thead>
<tr>
<th>int</th>
<th>long</th>
<th>float</th>
<th>complex</th>
</tr>
</thead>
<tbody>
<tr>
<td>10</td>
<td>51924361L</td>
<td>0.0</td>
<td>3.14j</td>
</tr>
<tr>
<td>100</td>
<td>-0x1932L</td>
<td>15.20</td>
<td>45.j</td>
</tr>
<tr>
<td>-786</td>
<td>0122L</td>
<td>-21.9</td>
<td>9.322e-36j</td>
</tr>
<tr>
<td>080</td>
<td>0xDEFABCECBDAECBFBAEI</td>
<td>32.3+e18</td>
<td>.876j</td>
</tr>
<tr>
<td>-0490</td>
<td>535633629843L</td>
<td>-90.</td>
<td>-.6545+0j</td>
</tr>
<tr>
<td>-0x260</td>
<td>-052318172735L</td>
<td>-32.54e100</td>
<td>3e+26j</td>
</tr>
<tr>
<td>0x69</td>
<td>-472188529L</td>
<td>70.2-E12</td>
<td>4.53e-7j</td>
</tr>
</tbody>
</table>
<ul>
<li>长整型也可以使用小写 “L”，但是还是建议使用大写 “L”，避免与数字 “1” 混淆。Python 使用 “L” 来显示长整型。</li>
<li>Python 还支持复数，复数由实数部分和虚数部分构成，可以用 a + bj,或者complex(a,b)表示， 复数的实部a和虚部b都是浮点型。</li>
</ul>
<h2 id="Python-Number-类型转换"><a href="#Python-Number-类型转换" class="headerlink" title="Python Number 类型转换"></a>Python Number 类型转换</h2><table>
<thead>
<tr>
<th>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</th>
<th>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</th>
</tr>
</thead>
<tbody>
<tr>
<td>int(x [,base ])</td>
<td>将x转换为一个整数  </td>
</tr>
<tr>
<td>long(x [,base ])</td>
<td>将x转换为一个长整数  </td>
</tr>
<tr>
<td>float(x )</td>
<td>将x转换到一个浮点数  </td>
</tr>
<tr>
<td>complex(real [,imag ])</td>
<td>创建一个复数  </td>
</tr>
<tr>
<td>str(x )</td>
<td>将对象 x 转换为字符串  </td>
</tr>
<tr>
<td>repr(x )</td>
<td>将对象 x 转换为表达式字符串  </td>
</tr>
<tr>
<td>eval(str )</td>
<td>用来计算在字符串中的有效Python表达式,并返回一个对象  </td>
</tr>
<tr>
<td>tuple(s )</td>
<td>将序列 s 转换为一个元组  </td>
</tr>
<tr>
<td>list(s )</td>
<td>将序列 s 转换为一个列表  </td>
</tr>
<tr>
<td>chr(x )</td>
<td>将一个整数转换为一个字符  </td>
</tr>
<tr>
<td>unichr(x )</td>
<td>将一个整数转换为Unicode字符  </td>
</tr>
<tr>
<td>ord(x )</td>
<td>将一个字符转换为它的整数值  </td>
</tr>
<tr>
<td>hex(x )</td>
<td>将一个整数转换为一个十六进制字符串  </td>
</tr>
<tr>
<td>oct(x )</td>
<td>将一个整数转换为一个八进制字符串</td>
</tr>
</tbody>
</table>
<h2 id="Python-数学函数"><a href="#Python-数学函数" class="headerlink" title="Python 数学函数"></a>Python 数学函数</h2><table>
<thead>
<tr>
<th>函数</th>
<th>返回值（描述）</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/1.%20Python%20abs(" target="_blank" rel="external">abs(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回数字的绝对值，如abs(-10) 返回 10</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/2.%20Pyhton%20ceil(" target="_blank" rel="external">ceil(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回数字的上入整数，如math.ceil(4.1) 返回 5</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/3.%20Pyhton%20cmp(" target="_blank" rel="external">cmp(x, y)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>如果 x &lt; y 返回 -1, 如果 x == y 返回 0, 如果 x &gt; y 返回 1</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/4.%20Python%20exp(" target="_blank" rel="external">exp(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回e的x次幂(ex),如math.exp(1) 返回2.718281828459045</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/5.%20Python%20fabs(" target="_blank" rel="external">fabs(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回数字的绝对值，如math.fabs(-10) 返回10.0</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/6.%20Python%20floor(" target="_blank" rel="external">floor(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回数字的下舍整数，如math.floor(4.9)返回 4</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/7.%20Python%20log(" target="_blank" rel="external">log(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>如math.log(math.e)返回1.0,math.log(100,10)返回2.0</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/8.%20Python%20log10(" target="_blank" rel="external">log10(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回以10为基数的x的对数，如math.log10(100)返回 2.0</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/9.%20Python%20max(" target="_blank" rel="external">max(x1, x2,…)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回给定参数的最大值，参数可以为序列。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/10.%20Python%20min(" target="_blank" rel="external">min(x1, x2,…)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回给定参数的最小值，参数可以为序列。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/11.%20Python%20modf(" target="_blank" rel="external">modf(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回x的整数部分与小数部分，两部分的数值符号与x相同，整数部分以浮点型表示。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/12.%20Python%20pow(" target="_blank" rel="external">pow(x, y)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>x**y 运算后的值。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/13.%20Python%20round(" target="_blank" rel="external">round(x [,n])</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回浮点数x的四舍五入值，如给出n值，则代表舍入到小数点后的位数。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E6%95%B0%E5%AD%A6%E5%87%BD%E6%95%B0/14.%20Python%20sqrt(" target="_blank" rel="external">sqrt(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回数字x的平方根，数字可以为负数，返回类型为实数，如math.sqrt(4)返回 2+0j</td>
</tr>
</tbody>
</table>
<h2 id="Python-随机数函数"><a href="#Python-随机数函数" class="headerlink" title="Python 随机数函数"></a>Python 随机数函数</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;随机数可以用于数学、游戏、安全等领域中，还经常被嵌入到算法中，用以提高算法效率，并提高程序的安全性。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Python 包含以下常用随机数函数：</p>
<table>
<thead>
<tr>
<th>函数</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E9%9A%8F%E6%9C%BA%E6%95%B0%E5%87%BD%E6%95%B0/1.%20Python%20choice(" target="_blank" rel="external">choice(seq)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>从序列的元素中随机挑选一个元素，比如random.choice(range(10))，从0到9中随机挑选一个整数。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E9%9A%8F%E6%9C%BA%E6%95%B0%E5%87%BD%E6%95%B0/2.%20Python%20randrange(" target="_blank" rel="external">randrange ([start,] stop [,step])</a>%E5%87%BD%E6%95%B0.md)</td>
<td>从指定范围内，按指定基数递增的集合中获取一个随机数，基数缺省值为1</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E9%9A%8F%E6%9C%BA%E6%95%B0%E5%87%BD%E6%95%B0/3.%20Python%20random(" target="_blank" rel="external">random()</a>%E5%87%BD%E6%95%B0.md)</td>
<td>随机生成下一个实数，它在[0,1)范围内。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E9%9A%8F%E6%9C%BA%E6%95%B0%E5%87%BD%E6%95%B0/4.%20Python%20seed(" target="_blank" rel="external">seed([x])</a>%E5%87%BD%E6%95%B0.md)</td>
<td>改变随机数生成器的种子seed。如果你不了解其原理，你不必特别去设定seed，Python会帮你选择seed。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E9%9A%8F%E6%9C%BA%E6%95%B0%E5%87%BD%E6%95%B0/5.%20Python%20shuffle(" target="_blank" rel="external">shuffle(lst)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>将序列的所有元素随机排序</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E9%9A%8F%E6%9C%BA%E6%95%B0%E5%87%BD%E6%95%B0/6.%20Pyhton%20uniform(" target="_blank" rel="external">uniform(x, y)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>随机生成下一个实数，它在[x,y]范围内。</td>
</tr>
</tbody>
</table>
<h2 id="Python-三角函数"><a href="#Python-三角函数" class="headerlink" title="Python 三角函数"></a>Python 三角函数</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Python 包括以下三角函数：</p>
<table>
<thead>
<tr>
<th>函数</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/1.%20Python%20acos(" target="_blank" rel="external">acos(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回x的反余弦弧度值。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/2.%20Python%20asin(" target="_blank" rel="external">asin(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回x的反正弦弧度值。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/3.%20Python%20atan(" target="_blank" rel="external">atan(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回x的反正切弧度值。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/4.%20Python%20atan2(" target="_blank" rel="external">atan2(y, x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回给定的 X 及 Y 坐标值的反正切值。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/5.%20Python%20cos(" target="_blank" rel="external">cos(x)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回x的弧度的余弦值。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/6.%20Python%20hypot(" target="_blank" rel="external">hypot(x, y)</a>%E5%87%BD%E6%95%B0.md)</td>
<td>返回欧几里德范数 sqrt(x<em>x + y</em>y)。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/7.%20Python%20sin(" target="_blank" rel="external">sin(x)</a>%20%E5%87%BD%E6%95%B0.md)</td>
<td>返回的x弧度的正弦值。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/8.%20Python%20tan(" target="_blank" rel="external">tan(x)</a>%20%E5%87%BD%E6%95%B0.md)</td>
<td>返回x弧度的正切值。</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/9.%20Python%20degrees(" target="_blank" rel="external">degrees(x)</a>%20%E5%87%BD%E6%95%B0.md)</td>
<td>将弧度转换为角度,如degrees(math.pi/2) ， 返回90.0</td>
</tr>
<tr>
<td><a href="https://github.com/hcldirgit/studygit/blob/master/Python%E4%B8%89%E8%A7%92%E5%87%BD%E6%95%B0/10.%20Python%20radians(" target="_blank" rel="external">radians(x)</a>%20%E5%87%BD%E6%95%B0.md)</td>
<td>将角度转换为弧度</td>
</tr>
</tbody>
</table>
<h2 id="Python-数学常量"><a href="#Python-数学常量" class="headerlink" title="Python 数学常量"></a>Python 数学常量</h2><table>
<thead>
<tr>
<th>常量</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>pi</td>
<td>数学常量 pi （圆周率，一般以π来表示）</td>
</tr>
<tr>
<td>e</td>
<td>数学常量 e ，e 即自然常数（自然常数）</td>
</tr>
</tbody>
</table>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Python/" rel="tag"># Python</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/08/10/Python/1. Python 基础篇/1. Python 基础语法/1.5 Python 的数值和字符串/7. Python 字符串/" rel="next" title="Python 字符串">
                <i class="fa fa-chevron-left"></i> Python 字符串
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/08/31/Shell 练习/1. shell 练习-每日生成一个文件/" rel="prev" title="shell 练习-每日生成一个文件">
                shell 练习-每日生成一个文件 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Python-Number（数字）"><span class="nav-number">1.</span> <span class="nav-text">Python Number（数字）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#Python-Number-类型转换"><span class="nav-number">1.1.</span> <span class="nav-text">Python Number 类型转换</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Python-数学函数"><span class="nav-number">1.2.</span> <span class="nav-text">Python 数学函数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Python-随机数函数"><span class="nav-number">1.3.</span> <span class="nav-text">Python 随机数函数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Python-三角函数"><span class="nav-number">1.4.</span> <span class="nav-text">Python 三角函数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Python-数学常量"><span class="nav-number">1.5.</span> <span class="nav-text">Python 数学常量</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
